﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Validators;

namespace SchEdu.Framework.Objective
{
    class Makespan : Objective
    {
        public Makespan()
            : base()
        {
        }
        public Makespan(SchEduData schEduData, SchEduDataSet.SolutionRow solution)
            : base(schEduData, solution)
        {
        }

        protected override void Logic()
        {
            int makespan = 0;
            int endDate = Int32.MinValue;

            foreach (SchEduDataSet.AllocationRow allocation in Solution.GetAllocationRows())
            {
                if (endDate < allocation.EndDate)
                {
                    endDate = allocation.EndDate;
                }
            }

            makespan = endDate;

            GeneratePerformanceRow();

            performance.Value = makespan;

        }

        public override AboutInfo AboutInfo
        {
            get
            {
                AboutInfo aboutInfo = new AboutInfo();
                aboutInfo.Title = "Makespan";
                aboutInfo.Guid = new Guid("{2F5ED7B6-76C5-4948-B4D9-7F11F531CCE1}");
                aboutInfo.Description = Resources.MakespanDescription;
                return aboutInfo;
            }
        }

    }
}
